@extends('app')
@include('UEditor::head')
@section('content')
<ul class="nav nav-tabs">
    <li><a href="{{ url('/admin/teaches/organization/class')}}">信息列表</a></li>
    <li class="active"><a href="{{ url('/admin/teaches/organization/class/create') }}">信息添加</a></li>
</ul>
<form id="newsForm" method="post" action="/admin/teaches/organization/class/update">
    <div class="panel panel-default description2">
        <div class="form-group">
            <!--             <label for="title" class="col-sm-2 control-label">标题：</label> -->
            <!--             <div class="col-sm-10"> -->
            <input type="text" class="form-control" name="name" id="name" placeholder="课程名称" value="{{ $course->name }}">
            <!--             </div> -->
        </div>
        <div class="form-inline mt20">
            <div class="form-group" id="parent">
                <label>选择机构：</label>
                <select name="org_id" class="form-control" id="type">
                    <option value="0">--无--</option>
                    @foreach($org as $og)
                    <option value="{{ $og->id }}" @if($og->id == $course->org_id) selected @endif>{{ $og->name }}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <h4>相册：</h4>
        <div class="form-group">
            <input id="uploadimg" name="uploadimg" type="file" multiple="true">
            <div id="imgbox" class="dustbin">
            @foreach($attachment as $at)
                <div style='width:90px; height:60px;float:left;'>
                    <img src='{{ $at->url }}' />
                    <input type='hidden' name='thumb' value='{{ $at->aid }}' />
                </div>
            @endforeach
            </div>
        </div>
        <h4>简介：</h4>
        <div class="form-group">
            <!--             <textarea class="form-control" rows="3" name="description" placeholder="在这里输入简介" id="description"></textarea> -->
            <!--             <div id="desc_tips"><i class="glyphicon glyphicon-envelope"></i><span class="font-tips">将右侧图库的图片拖入此处</span></div> -->
            <!--             <div id="desc_img_box" class="dustbin"></div> -->
            <script id="breif" name="breif"  style="width:100%;margin:0 auto;height:100px;" type="text/plain">
            </script>
        </div>
        <h4>介绍：</h4>
        <div class="form-group">
            <!-- 加载编辑器的容器 -->
            <script id="introduction" name="introduction"  style="width:100%;margin:0 auto;height:300px;" type="text/plain">
            </script>
            <!-- 实例化编辑器 -->
        </div>
        <h4>优惠活动：</h4>
        <div class="form-group">
            <!-- 加载编辑器的容器 -->
            <script id="activities" name="activities"  style="width:100%;margin:0 auto;height:300px;" type="text/plain">
            </script>
            <!-- 实例化编辑器 -->
        </div>
        <!--<div class="form-inline">
            <div class="form-group">
                <label>分页类型：</label>
                <select name="pagination" class="form-control">
                    <option value="0">不采用分页</option>
                    <option value="1">自动分页</option>
                    <option value="2">手动分页</option>
                </select>
            </div>
        </div>-->
        <!--<div class="form-inline mt20">
            <div class="form-group">
                <label >相关标签：</label>
                <strong id="newstags"></strong>
                <i class="glyphicon glyphicon-plus" data-toggle="modal" data-target="#myModal"></i>
            </div>
        </div>-->
        <div class="form-inline mt20">
            <div class="form-group">
                <label>费用：</label>
                <input type="text" class="form-control" name="cost" id="cost"
                       value="{{ $course->cost }}" placeholder="" style="width: 100px;">
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>评分：</label>
                <input type="text" class="form-control" name="score" id="score"
                       value="{{ $course->score }}" placeholder="<5的整数" style="width: 100px;">
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>效果：</label>
                <input type="text" class="form-control" name="effect" value="{{ $course->effect }}" id="effect" >
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>师资：</label>
                <input type="text" class="form-control" name="teachers" id="teachers" value="{{ $course->teachers }}"  placeholder="" >
            </div>
        </div>
        <div class="form-inline mt20">
            <div class="form-group">
                <label>环境：</label>
                <input type="text" class="form-control" name="environment" id="environment" value="{{ $course->environment }}"  placeholder="" >
            </div>
        </div>
        {!! csrf_field() !!}
        <input type="hidden" name="id" value="{{ $course->id }}">
        <div class="form-inline mt20">
            <div class="form-group">
                <input type="submit" class="btn btn-primary btn-block" id="organi_publish_save" value="保存并发布" />
            </div>
            <div class="form-group col-xs-offset-1">
                <input type="submit"  class="btn  btn-dinfo" id="employ_no_publish_save" value="submit" />
            </div>

            <div class="form-group col-xs-offset-1">
                <input type="reset" class="btn" value="reset" />
            </div>
        </div>
    </div>
</form>

<script type="text/javascript">
    <!--
    //    简介
    var ue = UE.getEditor('breif');
    ue.ready(function() {
        var breif = '@if(!empty($course)) {!! str_replace("\n","",$course->breif) !!} @endif';
        ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        ue.setContent(breif);
    });
    //    介绍
    var ue1 = UE.getEditor('introduction');
    ue1.ready(function() {
        var introduction = '@if(!empty($course)) {!! str_replace("\n","",$course->introduction) !!} @endif';
        ue1.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        ue1.setContent(introduction);

    });
    //    优惠活动
    var ue2 = UE.getEditor('activities');
    ue2.ready(function() {
        ue2.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        ue2.setContent('{!! $course->activities !!}');

    });

    $(function(){
        /***图片上传****/
        $("#uploadimg").uploadify({
            'formData'     : {
                'app':'course',
                'fileField':'upfile',
                '_token':'{{ csrf_token() }}'
            },
            "width"           : 120,
            "height"          : 30,
            "queueSizeLimit"  :1,
            "swf"             : "{{ asset('/js/uploadify/uploadify.swf') }}",
            "fileObjName"     : "upfile",
            "buttonText"      : "上传图片",
            "uploader"        : '/admin/upload/uploadimg',
            'removeTimeout'	  : 1,
            'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
            'onUploadSuccess':function(file, data, response){
                var data = eval('(' + data + ')');
                if (data.status == 'success') {

                    var html="<div style='width:90px; height:60px;float:left;'>"
                        +"<img src='"+data.attach+"' /><input type='hidden' name='thumb' value='"+data.attach_id+"' />"
                        +"</div>"
                    $('#imgbox').html(html);
//     	            bindImg();
                }else{
                    alert(data.msg);
                    return false;
                }

            }

        });
    });
    //-->
</script>
@endsection
